package com.project.controller;

import com.project.bean.CutPageBean;
import com.project.bean.ProductBean;
import com.project.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private ProductService service;
    @RequestMapping("findByItem")
    public CutPageBean<ProductBean> findByItem (int pageNo, String name, LocalDate startDate, LocalDate endDate){
        return service.findByItem(pageNo,name,startDate,endDate);
    }
    @RequestMapping("findById")
    public ProductBean findById(Integer id){
        return service.findById(id);
    }
    @RequestMapping("update")
    public String update(Integer id,Integer price){
        service.update(id,price);
        return "ok";
    }
    @RequestMapping("del")
    public String del(Integer id){
        service.del(id);
        return "ok";
    }
    @RequestMapping("add")
    public String add(ProductBean productBean){
        service.add(productBean);
        return "ok";
    }
}